package 刷题10月.每日一题0930;
// https://leetcode-cn.com/problems/number-of-segments-in-a-string/
public class 模拟434字符串中的单词数1007 {
    class Solution {
        public int countSegments(String s) {
            int n=s.length();
            int res=0;
            for(int i=0;i<n;){
                if (s.charAt(i) == ' ' && i++ >= 0) continue;
                while(i<n&&s.charAt(i)!=' '){
                    i++;
                }
                res++;
            }
            return res;
        }
    }
}
